let fs = require('fs')

let patt = new RegExp('compiled.js')

var deleteFolderRecursive = function(path) {
  var files = [];
  if( fs.existsSync(path) ) {
      files = fs.readdirSync(path)
      files.forEach(function(file,index){
          var curPath = path + "/" + file;
          if(fs.statSync(curPath).isDirectory()) { // recurse
              deleteFolderRecursive(curPath);
          } else { // delete file
              if (patt.test(file)) fs.unlinkSync(curPath);
          }
      });
  }
};

deleteFolderRecursive('./')